function PlotCR3BPSunEarth_EarthCenterView(t,S,u)

r12 = 1.496*10^8;
%[km]Distance between the Sun and the Earth.

Re = 6378.136 / r12;
%[]Normalized mean equatorial radius of the Earth.

Rs = 696340 / r12;
%[]Normalized mean equatorial radius of the sun.

[xe,ye,ze] = ellipsoid(1-u,0,0,Re,Re,Re,100);
%[]Coordinates for the Earth.

Rsat = S(1:3,:);
%[]Satellite positions WRT the CM in ECI coordinates.
Vsat = S(4:6,:);
[L1, L2, L3, L4, L5]=librationPoints(u);

Earth = imread('Earth.bmp');
%[]Loads the image of the Earth.

ScreenSize = get(0,'ScreenSize');
%[]Determines the location and dimensions of the current monitor.

Window = figure( ...
    'Color','w', ...
    'Name','CIRCULAR RESTRICTED THREE-BODY PROBLEM', ...
    'NumberTitle','Off', ...
    'OuterPosition',ScreenSize);
%[]Opens a new window and adjusts its properties.
n = size(Rsat,2);
%[]Number of points that will be plotted.
rsat = zeros(1,n);
%[]Allocates memory for the range vector.
for k = 1:n
    
    rsat(k) = norm(Rsat(:,k));
    %[Earth radii]Current range.
    
end
a = max(rsat);
if a < 1.2
    Extent = 1.2;
else
    Extent = ceil(max(rsat));
end
%[]Axes extents.

Axes = axes(...
'CameraPosition',[1,0,0.3], ...
'CameraTarget',[1,0,0],...
    'FontName','Arial', ...
    'FontSize',12, ...
    'FontWeight','Bold', ...
    'NextPlot','Add', ...
    'Parent',Window, ...
    'PlotBoxAspectRatio',[1,1,1], ...
    'XGrid','On', ...
    'YGrid','On', ...
    'ZGrid','On');
%[]Adds an axes to the specified window and adjusts its properties.
axis equal
surface(xe,ye,-ze, ...
    'CData',Earth, ...
    'EdgeColor','None', ...
    'FaceColor','TextureMap', ...
    'Parent',Axes);
%[]Adds a plot to the specified axes and adjusts its properties.

plot3(Rsat(1,:),Rsat(2,:),Rsat(3,:), ...
    'Color','k', ...
    'LineStyle','none', ...
    'Marker','.', ...
    'MarkerSize',8,...
    'Parent',Axes);
%[]Adds a plot to the specified window and adjusts its properties.
eps = 0.2;
for ii = [1,n/2]
    pts = [[Rsat(1,ii),Rsat(2,ii),Rsat(3,ii)];...
        [Rsat(1,ii)+eps*Vsat(1,ii),Rsat(2,ii)+eps*Vsat(2,ii),Rsat(3,ii)+eps*Vsat(3,ii)]];
    p1 = pts(1,:);
    p2 = pts(2,:);
    dp = p2-p1;      
    quiver3(p1(1),p1(2),p1(3),dp(1),dp(2),dp(3),'Color','r','LineWidth',4)
end

plot(L1(1),L1(2), ...
    'Color','k', ...
    'LineStyle','None', ...
    'Marker','.', ...
    'MarkerSize',5, ...
    'Parent',Axes);
%[]Plots the position of L1 and adjusts its properties.

plot(L2(1),L2(2), ...
    'Color','k', ...
    'LineStyle','None', ...
    'Marker','.', ...
    'MarkerSize',5, ...
    'Parent',Axes);
%[]Plots the position of L2 and adjusts its properties.

title( ...
    'SATELLITE ORBIT IN THE CR3BP', ...
    'FontSize',20, ...
    'Parent',Axes);
%[]Adds a title to the specified axes and adjusts its properties.

xlabel( ...
    '\chi_x', ...
    'FontSize',16, ...
    'Parent',Axes);
%[]Adds a label to the specified x-axis and adjusts its properties.

ylabel( ...
    '\chi_y', ...
    'FontSize',16, ...
    'Parent',Axes);
%[]Adds a label to the specified y-axis and adjusts its properties.

text( ...
    'FontName','Arial', ...
    'FontSize',12, ...
    'FontWeight','Bold', ...
    'HorizontalAlignment','Center', ...
    'Parent',Axes, ...
    'Position',[L1(1),-0.1], ...
    'String','L_1');
%[]Adds a textbox to the specified axes.

text( ...
    'FontName','Arial', ...
    'FontSize',12, ...
    'FontWeight','Bold', ...
    'HorizontalAlignment','Center', ...
    'Parent',Axes, ...
    'Position',[L2(1),-0.1], ...
    'String','L_2');
%[]Adds a textbox to the specified axes.
end

